import React, { Component } from 'react';
import {
  Icon
} from 'antd';

export default class Stars extends Component {
  static defaultProps = {
    className: "",
    starLevel: 1
  }

  constructor(props) {
    super(props);
    this.state = {}
  }

  render() {
    const { className, starLevel } = this.props;
    return <div className={className ? "stars " + className : "stars"}>
      {this.renderStars(starLevel)}
    </div>
  }

  renderStars(starLevel) {
    let stars = [];
    for (let i = 0; i < starLevel; i++) {
      stars.push(<Icon type="star" key={i} />)
    }
    for (let i = 0; i < 5 - starLevel; i++) {
      stars.push(<Icon type="star-o" key={starLevel + i} />)
    }
    return stars;
  }
}